/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.widgetscorrepondances.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import uimigration.widgetscorrepondances.ChoiceModel;
import uimigration.widgetscorrepondances.FUIElement;
import uimigration.widgetscorrepondances.WidgetscorrepondancesPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Choice Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.widgetscorrepondances.impl.ChoiceModelImpl#getUimodel <em>Uimodel</em>}</li>
 *   <li>{@link uimigration.widgetscorrepondances.impl.ChoiceModelImpl#getUielements <em>Uielements</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ChoiceModelImpl extends EObjectImpl implements ChoiceModel {
	/**
	 * The default value of the '{@link #getUimodel() <em>Uimodel</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUimodel()
	 * @generated
	 * @ordered
	 */
	protected static final String UIMODEL_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getUimodel() <em>Uimodel</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUimodel()
	 * @generated
	 * @ordered
	 */
	protected String uimodel = UIMODEL_EDEFAULT;

	/**
	 * The cached value of the '{@link #getUielements() <em>Uielements</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUielements()
	 * @generated
	 * @ordered
	 */
	protected EList<FUIElement> uielements;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChoiceModelImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WidgetscorrepondancesPackage.Literals.CHOICE_MODEL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getUimodel() {
		return uimodel;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUimodel(String newUimodel) {
		String oldUimodel = uimodel;
		uimodel = newUimodel;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WidgetscorrepondancesPackage.CHOICE_MODEL__UIMODEL, oldUimodel, uimodel));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<FUIElement> getUielements() {
		if (uielements == null) {
			uielements = new EObjectContainmentEList<FUIElement>(FUIElement.class, this, WidgetscorrepondancesPackage.CHOICE_MODEL__UIELEMENTS);
		}
		return uielements;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.CHOICE_MODEL__UIELEMENTS:
				return ((InternalEList<?>)getUielements()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.CHOICE_MODEL__UIMODEL:
				return getUimodel();
			case WidgetscorrepondancesPackage.CHOICE_MODEL__UIELEMENTS:
				return getUielements();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.CHOICE_MODEL__UIMODEL:
				setUimodel((String)newValue);
				return;
			case WidgetscorrepondancesPackage.CHOICE_MODEL__UIELEMENTS:
				getUielements().clear();
				getUielements().addAll((Collection<? extends FUIElement>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.CHOICE_MODEL__UIMODEL:
				setUimodel(UIMODEL_EDEFAULT);
				return;
			case WidgetscorrepondancesPackage.CHOICE_MODEL__UIELEMENTS:
				getUielements().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WidgetscorrepondancesPackage.CHOICE_MODEL__UIMODEL:
				return UIMODEL_EDEFAULT == null ? uimodel != null : !UIMODEL_EDEFAULT.equals(uimodel);
			case WidgetscorrepondancesPackage.CHOICE_MODEL__UIELEMENTS:
				return uielements != null && !uielements.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (uimodel: ");
		result.append(uimodel);
		result.append(')');
		return result.toString();
	}

} //ChoiceModelImpl
